package com.nbsaas.boot.project.rest.convert;

import com.nbsaas.boot.project.data.entity.BusinessModelField;
import com.nbsaas.boot.project.api.domain.simple.BusinessModelFieldSimple;

import com.nbsaas.boot.rest.api.Converter;
import java.util.HashMap;
import java.util.Map;

/**
* 列表对象转换器
*/

public class BusinessModelFieldSimpleConvert implements Converter<BusinessModelFieldSimple, BusinessModelField> {




@Override
public BusinessModelFieldSimple convert(BusinessModelField source) {
    BusinessModelFieldSimple result = new BusinessModelFieldSimple();

                result.setNote(source.getNote());
                if(source.getDataType()!=null){
                    result.setDataTypeName(source.getDataType().getName());
                }
                if(source.getBusinessModel()!=null){
                    result.setBusinessModel(source.getBusinessModel().getId());
                }
                if(source.getDataType()!=null){
                    result.setDataType(source.getDataType().getId());
                }
                result.setName(source.getName());
                result.setEnName(source.getEnName());
                if(source.getShowType()!=null){
                   Map<Integer,String> ShowTypeMap=new HashMap<>();
                       ShowTypeMap.put(1,"显示");
                       ShowTypeMap.put(2,"不显示");
                   String label=  ShowTypeMap.get(source.getShowType());
                   result.setShowTypeName(label);
                }
                result.setShowType(source.getShowType());
                if(source.getBusinessModel()!=null){
                    result.setBusinessModelName(source.getBusinessModel().getName());
                }
                result.setId(source.getId());
                result.setProjectId(source.getProjectId());


    return result;
}

}